package com.zl.tby.vo;

import com.zl.tby.core.base.util.ToolsUtil;
import com.zl.tby.model.TbyMonitoringStation;
import lombok.Data;
import org.noear.solon.validation.annotation.Length;
import org.noear.solon.validation.annotation.NotBlank;
import org.noear.solon.validation.annotation.NotNull;

import java.util.Date;

/**
 * 监测站点
 * @author changpeng
 * @version 1.0
 * @since 2024/8/6 20:12
 */
@Data
public class TbyMonitoringStationForm {
    /**主键id*/
    private Long id;
    /**设备名称*/
    @NotBlank(message = "设备名称不能为空")
    @Length(max = 20, message = "设备名称最大长度为20")
    private String deviceName;
    /**设备编码*/
    @NotBlank(message = "设备编码不能为空")
    @Length(max = 255, message = "设备编码最大长度为255")
    private String deviceCode;
    /**设备类型*/
    @NotBlank(message = "设备类型不能为空")
    @Length(max = 255, message = "设备类型最大长度为255")
    private String deviceType;
    /**设备型号*/
    @NotBlank(message = "设备型号不能为空")
    @Length(max = 20, message = "设备型号最大长度为20")
    private String deviceModel;
    /**经度*/
    @NotBlank(message = "山峰经度不能为空")
    @Length(max = 32, message = "山峰经度最大长度为32")
    private String longitude;
    /**纬度*/
    @NotBlank(message = "山峰纬度不能为空")
    @Length(max = 32, message = "山峰纬度最大长度为32")
    private String latitude;
    /**监测参数数量*/
    @NotNull(message = "监测参数数量不能为空")
    private Integer paramsCount;
    /**负责人*/
    @Length(max = 32, message = "32")
    private String headName;
    /**建设时间*/
    private Date buildDate;
    private String buildDateFormat;

    public static TbyMonitoringStationForm recordConvert(TbyMonitoringStation item) {
        TbyMonitoringStationForm entity = new TbyMonitoringStationForm();
        entity.setId(item.getId());
        entity.setDeviceName(item.getDeviceName());
        entity.setDeviceCode(item.getDeviceCode());
        entity.setDeviceType(item.getDeviceType());
        entity.setDeviceModel(item.getDeviceModel());
        entity.setLongitude(item.getLongitude());
        entity.setLatitude(item.getLatitude());
        entity.setParamsCount(item.getParamsCount());
        entity.setHeadName(item.getHeadName());
        entity.setBuildDate(item.getBuildDate());
        entity.setBuildDateFormat(ToolsUtil.dateUtil2String(item.getBuildDate(), "yyyy-MM-dd"));
        return entity;
    }

    public TbyMonitoringStation createEntity() {
        TbyMonitoringStation entity = new TbyMonitoringStation();
        entity.setId(this.getId());
        entity.setDeviceName(this.getDeviceName());
        entity.setDeviceCode(this.getDeviceCode());
        entity.setDeviceType(this.getDeviceType());
        entity.setDeviceModel(this.getDeviceModel());
        entity.setLongitude(this.getLongitude());
        entity.setLatitude(this.getLatitude());
        entity.setParamsCount(this.getParamsCount());
        entity.setHeadName(this.getHeadName());
        entity.setBuildDate(this.getBuildDate());
        return entity;
    }

    public void updateEntity(TbyMonitoringStation entity) {
        entity.setId(this.getId());
        entity.setDeviceName(this.getDeviceName());
        entity.setDeviceCode(this.getDeviceCode());
        entity.setDeviceType(this.getDeviceType());
        entity.setDeviceModel(this.getDeviceModel());
        entity.setLongitude(this.getLongitude());
        entity.setLatitude(this.getLatitude());
        entity.setParamsCount(this.getParamsCount());
        entity.setHeadName(this.getHeadName());
        entity.setBuildDate(this.getBuildDate());
    }
}
